#include "meshdrawableactor.h"
#include "stringproperty.h"
#include "mesh.h"
#include "datatypedefine.h"
#include "datamanager.h"

namespace VrDataCore
{
	MeshDrawableActor::MeshDrawableActor()
	{
		setClassName(CLASS_MODEL);
	}

	MeshDrawableActor::~MeshDrawableActor()
	{}

	void MeshDrawableActor::buildPropertyMap()
	{
		addProperty(new StringProperty<DrawableActor>(XML_ELEMENT_DATATYPE_STRING,
			"Parent ID","",this,&DrawableActor::setParentID,
			&DrawableActor::getParentID,"",""));
		addProperty(new StringProperty<MeshDrawableActor>(XML_ELEMENT_DATATYPE_STRING,
			ACTOR_PROPERYT_MESH,"",this,&MeshDrawableActor::setMesh,
			&MeshDrawableActor::getMesh,"",""));
	}

	void MeshDrawableActor::setMesh(QString mesh)
	{
		dynamic_cast<Mesh*>(_drawable.get())->setMeshFile(mesh);
	}

	QString MeshDrawableActor::getMesh()
	{
		return dynamic_cast<Mesh*>(_drawable.get())->getMeshFile();;
	}

	void MeshDrawableActor::createDrawable()
	{
		_drawable = new Mesh(this);
		useStateSet();
	}
}